home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Utils / GParted Live CD / Bin / gparted-livecd-0.2.2.iso / fake / needwrite / etc / rc.d / init.d / rc < prev    next >
Encoding:
Text File  |  2006-01-27  |  2.4 KB  |  95 lines

  1. #!/bin/sh
  2. # Begin $rc_base/init.d/rc - Main Run Level Control Script
  3.  
  4. # Based on rc script from LFS-3.1 and earlier.
  5. # Rewritten by Gerard Beekmans  - gerard@linuxfromscratch.org
  6.  
  7. . /etc/sysconfig/rc
  8. . $rc_functions
  9.  
  10. # This sets a few default terminal options.
  11. stty sane
  12.  
  13. # These 3 signals will not cause our script to exit
  14. trap "" INT QUIT TSTP
  15.  
  16. [ "$1" != "" ] && runlevel=$1
  17.  
  18. if [ "$runlevel" = "" ]
  19. then
  20.         echo "Usage: $0 <runlevel>" >&2
  21.         exit 1
  22. fi
  23.  
  24. previous=$PREVLEVEL
  25. [ "$previous" = "" ] && previous=N
  26.  
  27. if [ ! -d $rc_base/rc$runlevel.d ]
  28. then
  29.         echo "$rc_base/rc$runlevel.d does not exist"
  30.         exit 1
  31. fi
  32.  
  33. # Attempt to stop all service started by previous runlevel,
  34. # and killed in this runlevel
  35. if [ "$previous" != "N" ]
  36. then
  37.         for i in $(ls -v $rc_base/rc$runlevel.d/K* 2> /dev/null)
  38.         do
  39.  
  40.                 check_script_status
  41.  
  42.                 suffix=${i#$rc_base/rc$runlevel.d/K[0-9][0-9]}
  43.                 prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix
  44.                 sysinit_start=$rc_base/rcsysinit.d/S[0-9][0-9]$suffix
  45.  
  46.                 if [ "$runlevel" != "0" ] && [ "$runlevel" != "6" ]
  47.                 then
  48.                         if [ ! -f $prev_start ] && [ ! -f $sysinit_start ]
  49.                         then
  50.                                 echo -n -e $WARNING
  51.                                 echo "$i can't be executed because it was"
  52.                                 echo "not started in the previous runlevel ($previous)"
  53.                                 echo -n -e $NORMAL
  54.                                 continue
  55.                         fi
  56.                 fi
  57.                 $i stop
  58.                 error_value=$?
  59.  
  60.                 if [ "$error_value" != "0" ]
  61.                 then
  62.                         print_error_msg
  63.                 fi
  64.         done
  65. fi
  66.  
  67. #Start all functions in this runlevel
  68. for i in $( ls -v $rc_base/rc$runlevel.d/S* 2> /dev/null)
  69. do
  70.         if [ "$previous" != "N" ]
  71.         then
  72.                 suffix=${i#$rc_base/rc$runlevel.d/S[0-9][0-9]}
  73.                 stop=$rc_base/rc$runlevel.d/K[0-9][0-9]$suffix
  74.                 prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix
  75.  
  76.                 [ -f $prev_start ] && [ ! -f $stop ] && continue
  77.         fi
  78.  
  79.         check_script_status
  80.  
  81.     case $runlevel in
  82.                 0|6) $i stop    ;;
  83.         *)   $i start    ;;
  84.     esac
  85.         error_value=$?
  86.  
  87.         if [ "$error_value" != "0" ]
  88.         then
  89.                 print_error_msg
  90.         fi
  91. done
  92.  
  93.  
  94. # End $rc_base/init.d/rc
  95.